package tubesrus.beans;

import java.util.ArrayList;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "Utilisateur")
public class Utilisateur {

	@Id
	@Column(name = "ID", unique=true, nullable = false)
	private String id = null;
	@Column(name = "PASSWORD", nullable = false)
	private String password = null;
	@Column(name = "NOM", nullable = true)
	private String nom = "";
	@Column(name = "PRENOM", nullable = true)
	private String prenom = "";
	@Column(name = "EMAIL", unique=true, nullable = false)
	private String email;
	@Column(name = "SEXE", nullable = false)
	private String sexe = null;	
	@Column(name = "STATUT", nullable = false)
	private String statut = "confirmation";
	@Column(name = "VIDZ", nullable = false)
	private int vidz = 100;
	@Column(name = "NBCOMM", nullable = false)
	private int nbComm = 0;
	@Column(name = "NBCOMMSUP", nullable = false)
	private int nbCommSup = 0;
	@Column(name = "VIDEOSPAYEES", nullable = true)
	private ArrayList<Long> videosPayees = new ArrayList<Long>();
	@Column(name = "URLAVATAR", nullable = true)
	private String urlAvatar = "avatar.jpg";
	
	public String getUrlAvatar() {
		return urlAvatar;
	}

	public void setUrlAvatar(String urlAvatar) {
		this.urlAvatar = urlAvatar;
	}

	public int getNbComm() {
		return nbComm;
	}

	public void setNbComm(int nbComm) {
		this.nbComm = nbComm;
	}
	
	public void incNbComm() {
		this.nbComm++;
	}

	public int getNbCommSup() {
		return nbCommSup;
	}
	
	public void incNbCommSup() {
		this.nbCommSup++;
	}

	public void setNbCommSup(int nbCommSup) {
		this.nbCommSup = nbCommSup;
	}

	public void setVidz(int vidz) {
		this.vidz = vidz;
	}

	public void setVideosPayees(ArrayList<Long> videosPayees) {
		this.videosPayees = videosPayees;
	}
	
	public String toString(){
		return "[Utilisateur: "+id+" ("+prenom+" "+nom+")]";
	}
	
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getStatut() {
		return statut;
	}
	
	public void setStatut(String statut) {
		this.statut = statut;
	}
	
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getNom() {
		return nom;
	}
	public void setNom(String nom) {
		this.nom = nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public void addVidz(int vidz) {
		this.vidz += vidz;
	}
	
	public void removeVidz(int vidz) {
		this.vidz -= vidz;
	}

	public int getVidz() {
		return vidz;
	}

	public void addVideoPayee(Long vp) {
		System.out.println("ADDED???");
		if(!videosPayees.contains(vp)) {
			videosPayees.add(vp);
			System.out.println("ADDED!!!");
		}
		
	}

	public ArrayList<Long> getVideosPayees() {
		return videosPayees;
	}

	public void setSexe(String sexe) {
		this.sexe = sexe;
	}

	public String getSexe() {
		return sexe;
	}

}